package com.ht.yml.tools;

import java.util.Map;

/**
 * @author wangmin
 * @discription
 * @created 2024-12-30 10:51
 */
public class TesterForGenerateFromOtherEnvConfig {
    public static void main(String[] args) {
        final String copyFromEnv = "pro";
        final String targetEnv = "dev";


        // 1 加载程序配置
        final Map<String, Object> newApplicationConfig = ApplicationConfigUtils.generateApplicationConfigMapByYmlFile(targetEnv);


        // 2 加载 同一个 应用 已配置环境 的配置
        final Map<String, Object> existEnvConfig = ApolloConfigUtils.loadApolloConfig(Const.destAppId, copyFromEnv+".yaml");


        // 3 生成 新应用 app_const.yaml 样例配置
        final Map<String, Object> newEnvConfig = YamlPropertiesUtils.specialJoin(newApplicationConfig, "应用"+targetEnv+"配置", existEnvConfig, "应用"+copyFromEnv+"配置", true);


        System.out.println("新应用 "+targetEnv+"环境 样例配置 (按需增减属性) : ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓");
        String newEnvConfig_yamlStr = YamlReader.dump(newEnvConfig);
        System.out.println(newEnvConfig_yamlStr);
        System.out.println("新应用 "+targetEnv+"环境 样例配置 (按需增减属性) : '↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑\n\n\n");

    }

}
